package cn.bandeqing.worker.controller;

import cn.bandeqing.base.resp.Resp;
import cn.bandeqing.base.resp.Table;
import cn.bandeqing.worker.req.*;
import cn.bandeqing.worker.resp.WorkerTable;
import cn.bandeqing.worker.rpc.IWorkRpc;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/worker")
@RestController
@Tag(name = "工作人员 - 收纳 小哥")
public class WorkerController {

    @DubboReference
    private IWorkRpc workRpc;

    @Operation(summary = "modifyLevel")
    @PostMapping("/modifyLevel")
    public Resp<Void> modifyLevel(@RequestBody @Valid ModifyLevelReq req) {
        workRpc.modifyLevel(req);
        return Resp.success();
    }

    @Operation(summary = "modifyStatus")
    @PostMapping("/modifyStatus")
    public Resp<Void> modifyStatus(@RequestBody @Valid ModifyStatusReq req) {
        workRpc.modifyStatus(req);
        return Resp.success();
    }

    @Operation(summary = "resetPwd")
    @PostMapping("/resetPwd")
    public Resp<Void> resetPwd(@RequestBody @Valid ResetPwdReq req) {
        return workRpc.resetPwd(req);
    }

    @Operation(summary = "table")
    @PostMapping("/table")
    public Resp<Table<WorkerTable>> table(@RequestBody @Valid WorkerTableReq req) {
        return workRpc.table(req);
    }

    @Operation(summary = "创建或更新")
    @PostMapping("/saveOrUpdate")
    public Resp<Void> saveOrUpdate(@RequestBody @Valid WorkerSaveOrUpdateReq req) {
        workRpc.saveOrUpdate(req);
        return Resp.success();
    }

}
